<?php
class Product extends Front_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('product/product_model','product');
		$this->load->model('product/product_category_model','pcat');
	}
	
	public function index($cat=FALSE)
	{
		//$this->db->debug = true;
		$data['cat_id'] = $cat;	
		$condition = $cat > 0 ? "  product.cat_lv1 =".$cat."  " :"";
		$data['cat_name'] = $cat > 0 ? $this->db->getone("SELECT name FROM product_category WHERE ID=".$cat) : "";
		$data['product'] = $this->product->where($condition)->order_by('show_no','desc')->get();
		$data['pagination'] = $this->product->pagination();			
		$this->template->build('index',$data);				
	}
	public function detail($id=FALSE)
	{			
		$data['rs'] = $this->product->get_row($id);		 
		$this->template->build('detail',$data);
	}
}
?>